package com.chen.user.service.impl;

import com.chen.model.entity.user.UserAddress;
import com.chen.service.util.AuthContextUtil;
import com.chen.user.mapper.UserAddressMapper;
import com.chen.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author cgj
 * @date 4/26/25 9:03 AM
 */
@Service
public class UserAddressServiceImpl implements UserAddressService {
    @Autowired
    private UserAddressMapper userAddressMapper;
    /**
     * 获取用户地址列表
     * @return
     */
    @Override
    public List<UserAddress> findUserAddressList() {
        //获取当前用户的id
        Long userid = AuthContextUtil.get().getId();
        List<UserAddress> userAddressList=  userAddressMapper.selectUserAddressList(userid);
        return userAddressList;
    }

    /**
     *  根据地址id, 返回用户地址对象
     * @param id
     * @return
     */
    @Override
    public UserAddress getAddrById(Long id) {
        return userAddressMapper.selectAddrById(id);
    }
}
